<?php

class Model_Group extends Base_Model
{
    protected $_tableName = 'Table_Group';
    
	protected $_fields = array(
			'aid','gid','vid','name','area'
		);


    protected function filterGid()
    {
        if ($this->gid) {
            $village = new Model_Village();
            $village->readByUser();
            $this->vid = $village->vid;
        }
    }
    
    public function getVillage()
    {
        if (!$this->issetProperty('village')) {
            $village = new Model_Village();
            $village->readBy('vid', $this->vid);
            $this->setProperty('village', $village);
        }
        
        return $this->getProperty('village');
    }
    
    public function getStreet()
    {
        $village = $this->getVillage();
        
        if (!$this->issetProperty('street')) {
            $street = new Model_Street();
            $street->readBy('sid', $village->sid);
            $this->setProperty('street', $street);
        }
        
        return $this->getProperty('street');
    }
}